"""Initial

Revision ID: 631b74bda04d
Revises: 
Create Date: 2023-12-20 09:06:34.373502

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "631b74bda04d"
down_revision = None
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "admin_user",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("email", sa.String(length=100), nullable=False),
        sa.Column("password", sa.String(length=255), nullable=False),
        sa.Column("name", sa.String(length=100), nullable=False),
        sa.Column("can_export", sa.Boolean(), server_default="0", nullable=False),
        sa.Column("can_delete", sa.Boolean(), server_default="0", nullable=True),
        sa.Column("can_edit", sa.Boolean(), server_default="0", nullable=True),
        sa.Column("can_add", sa.Boolean(), server_default="0", nullable=True),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_admin_user")),
        sa.UniqueConstraint("email", name=op.f("uq_admin_user_email")),
    )
    op.create_table(
        "discount",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("title", sa.String(length=255), nullable=False),
        sa.Column("text", sa.TEXT(), nullable=False),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_discount")),
    )
    op.create_table(
        "payment_details",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column(
            "currency", sa.Enum("rub", "usdt", "kzt", name="currency"), nullable=False
        ),
        sa.Column(
            "currency_symbol",
            sa.Enum("rub", "usdt", "kzt", name="currencysymbol"),
            server_default="rub",
            nullable=False,
        ),
        sa.Column("payment_address", sa.String(length=255), nullable=False),
        sa.Column("payment_image_path", sa.String(length=255), nullable=True),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_payment_details")),
    )
    op.create_table(
        "review",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("review_text", sa.TEXT(), nullable=False),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_review")),
    )
    op.create_table(
        "user",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column(
            "role",
            sa.Enum("user", "admin", name="userrole"),
            server_default="user",
            nullable=False,
        ),
        sa.Column("telegram_id", sa.BigInteger(), nullable=False),
        sa.Column("username", sa.String(length=255), nullable=False),
        sa.Column("selected_account_id", sa.Integer(), nullable=True),
        sa.Column(
            "is_subscribed",
            sa.Boolean(),
            server_default=sa.text("false"),
            nullable=False,
        ),
        sa.Column(
            "is_approved", sa.Boolean(), server_default=sa.text("false"), nullable=False
        ),
        sa.Column(
            "lang_code",
            sa.Enum("ru", name="langcode"),
            server_default="ru",
            nullable=False,
        ),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_user")),
        sa.UniqueConstraint("telegram_id", name=op.f("uq_user_telegram_id")),
    )
    op.create_table(
        "account",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("account_id", sa.Integer(), nullable=False),
        sa.Column(
            "status",
            sa.Enum("on_moderation", "approved", name="accountstatus"),
            server_default="on_moderation",
            nullable=False,
        ),
        sa.Column("user_id", sa.Integer(), nullable=False),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.ForeignKeyConstraint(
            ["user_id"], ["user.id"], name=op.f("fk_account_user_id_user")
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_account")),
    )
    op.create_table(
        "deposit",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column(
            "status",
            sa.Enum("paid", "waiting_payment", "payment_failed", name="depositstatus"),
            server_default="waiting_payment",
            nullable=False,
        ),
        sa.Column("summ", sa.Float(), nullable=False),
        sa.Column("user_id", sa.Integer(), nullable=False),
        sa.Column("account_id", sa.Integer(), nullable=False),
        sa.Column("payment_method_id", sa.Integer(), nullable=True),
        sa.Column("invoice_screenshot_path", sa.String(length=255), nullable=True),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.ForeignKeyConstraint(
            ["account_id"], ["account.id"], name=op.f("fk_deposit_account_id_account")
        ),
        sa.ForeignKeyConstraint(
            ["payment_method_id"],
            ["payment_details.id"],
            name=op.f("fk_deposit_payment_method_id_payment_details"),
        ),
        sa.ForeignKeyConstraint(
            ["user_id"], ["user.id"], name=op.f("fk_deposit_user_id_user")
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_deposit")),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("deposit")
    op.drop_table("account")
    op.drop_table("user")
    op.drop_table("review")
    op.drop_table("payment_details")
    op.drop_table("discount")
    op.drop_table("admin_user")
    # ### end Alembic commands ###
